package com.luguangtao.controller;

import com.github.pagehelper.PageInfo;
import com.luguangtao.api.GoodsApi;
import com.luguangtao.entity.Goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@CrossOrigin
public class GoodsController2 {

    @Autowired
    GoodsApi goodsApi;
/*    @Autowired
    FileApi fileApi;*/

    //列表
    @RequestMapping("lists")
    public PageInfo lists(@RequestParam(defaultValue = "1") Integer pageNum,String gsname,String ss){
        PageInfo pageInfo = goodsApi.lists1(pageNum,gsname,ss);
        return pageInfo;
    }
    //添加
    @RequestMapping("addGoods")
    public String addGoods(Goods goods){
        return goodsApi.addGoods1(goods);
    }

    //删除
    @RequestMapping("del")
    public String del(String goodsid){
       return goodsApi.del1(goodsid);
    }

    //回显
    @RequestMapping("getGoods")
    public Goods getGoods(String goodsid){
        Goods goods1 = goodsApi.getGoods1(goodsid);
        return goods1;
    }
    //修改
    @RequestMapping("updateGoods")
    public String updateGoods(Goods goods){
        return goodsApi.updateGoods1(goods);
    }

   /*
    @ResponseBody
    @PostMapping("updateLoad")
    public String updateLoad(MultipartFile file){
        return goodsApi.uploadPic1(file);
    }

    @RequestMapping("downLoad")
    public void downLoad(HttpServletResponse response,HttpServletRequest request,@RequestParam("fileName")String filename){
        System.out.println("filename="+filename);
        goodsApi.downLoad1(response,request,filename);
    }*/
}
